<!--隐患整改 -->
<template>
    <div class="page troubleApply-page" data-page="troubleApply" style="z-index: 2">
        <div class="link-page-nav">
            <a href="#" class="link"  @click="$root.backToTab()">
                <i class="iconfont icon-zuo"></i>
            </a>
        </div>
        <div class="link-page-top" style="padding-bottom: 17px;">
            <div class="link-page-title">隐患整改</div>
            <a href="#" class="link popover-open" data-popover="#troubleHidden_menu" style="color: #000;">
                <i class="iconfont icon-APPicon_shaixuan1
" id="active" style="font-size: 23px;"></i>
            </a>
        </div>
        <div class="link-page-tab">
            <div class="troubleApply-type">
                <div id="tb-appoint" class="">待指派</div>
                <div id="tb-changeing" class="select">整改</div>
                <div id="tb-verify" class="">核实</div>
                <div id="tb-complete" class="">完成</div>
            </div>
        </div>
        <!-- 待指派 -->
        <div  class="troubleApply-tab-con tab page-content infinite-scroll-content" id="check-content" style="padding-bottom: 100px;"
            data-infinite-distance="80"  
            @infinite="loadMore">
            <div class="list media-list">
                <ul id="troubleApplyList" class="troubleApply-list" ></ul>
            </div>
            <div class="preloader infinite-scroll-preloader" id="trouble_preloader"></div>
        </div>
        
        <div class="more-task-btn" @click="createTrouble">
            <i class="iconfont icon-weibiaoti--1"></i>
        </div>

        <div class="popover select-option-con" id="troubleHidden_menu">
          <div class="popover-angle"></div>
          <div class="popover-inner">
            <div class="list">
              <ul>
                <li><a href="" class="list-button item-link popover-close" id="hidden_org">选择单位</a></li>
                <li><a href="" class="list-button item-link popover-close" id="hidden_level">隐患等级</a></li>
                <li><a href="" class="list-button item-link popover-close" id="hidden_type">隐患类别</a></li>
                <li><a href="" class="list-button item-link popover-close" @click="getTbTime" id="hidden_date">选择日期</a></li>
                <li><a href="" class="list-button item-link popover-close removeScreen select-active" @click="removeScreen" >清&nbsp&nbsp&nbsp&nbsp&nbsp空</a></li>
              </ul>
            </div>
            </div>
        </div>
    </div>
</template>
<style scoped>
.overTime-info{
    background-color: rgb(233, 241, 250);
    height: initial;
    border-radius: 0px 0px 6px 6px;
    font-size: 15px;
    position: relative;
}
.time{
    background-color: rgba(36, 113, 202, 0.5);
    color: #fff;
    padding: 3px 3px;
    padding-right: 5px;
    border-radius: 2px;
    font-family: LcdD;
}
.dot{
    color: rgba(36, 113, 202, 0.6);
    margin: -2px;
}
.overtime{
    background-color: #E07762;
    color: #fff;
    padding: 4px 3px;
    padding-right: 5px;
    border-radius: 2px;
    font-family: LcdD;
}
.overdot{
    color:#E07762;
    margin: -2px;
}
.overtime-icon{
    color: white;
    background-color: red;
    font-size: 12px;
    padding: 1px 5px;
    border-radius: 2px;
}
.wait-icon{
    width: 12px;
    height: 12px;
    margin-right: 8px;
}
.myImg{
    width: 28%;
    height: 75px;
    border-radius: 2px;
    padding-right: 10px;
}
.one-pic{
    width: 100%;
    height: 140px;
}
.more-pics{
    height: 75px;
    padding-left: 16px;
}
.ringht-con{
    font-size: 12px;
    margin-left:15px;
}
.appoint-to-do{
    width: 86px;
    background: #E07762;
    color: #fff;
    padding: 5px 0;
    border-radius: 15px;
    text-align: center;
    float: right;
    margin: 20px 15px 10px;
    font-size: 14px;
  
}
.toDo-con{
    background-color: #FCF1EF;
    font-size: 12px;
    padding: 12px 0;
    padding-left: 15px;
    overflow: hidden;
    color: #E07762;
}
.toDo-other-con{
    background-color: #E9F1FA;
    font-size: 12px;
    padding: 12px 0;
    padding-left: 15px;
    color: #2471CA;
}
.time-con{
    font-size: 12px;
    color: #999999;  
}
.time-con span{
    margin-left: 5px;
}
.troubleApply-list li{
    background: #ffffff;
    border: 1px solid rgba(225, 225, 225, 0.9);
    box-shadow: 0px 1px 10px 0px rgba(181, 200, 206, 0.5);
    border-radius: 6px;
    margin: 0 20px;
    margin-bottom: 20px;
}
.tb-voice-after{
    width: 100%;
    height: 35px;
    line-height: 35px;
}
.tb-voice-after-time{
    width: 100%;
    height: 100%;
    color: #fff;
    text-align: left;
    float: left;
    background: #378bf6;
}
.tb-voice-gif{
    height: 16px!important;
    width: 13px!important;
    margin: 3px;
}
.md .navbar~* .page-content, .md .navbar~.page-content{
    padding-top: 0px;
}
.yh-list .eqType{
    padding: 1px 5px;
    background: #ffc944;
    border-radius: 4px;
    color: #fff;
    font-size: 12px;
    border-radius: 2px;
}
</style>
<script>
return {
    mounted() {
        var self = this;
        var $ = self.$;
        self.selectIndex = self.$route.params.tabID;
        self.collect = self.$route.params.isCollect;
        if (single_Orgid == "") {
          self.orgIds=userInfor.organizationIds;
        } else {
          self.orgIds=single_Orgid;
        }
        if(self.selectIndex==0){
            self.status=1; 
            hiddenDangerListStatus=0; 
        }else if(self.selectIndex==1){
            self.status=3;
            hiddenDangerListStatus=1;
        }else if(self.selectIndex==2){
            self.status=2;
            hiddenDangerListStatus=2;
        }else{
            self.status=5;
            hiddenDangerListStatus=5;
        }
        $(".troubleApply-type div").removeClass('select').eq((self.selectIndex)).addClass('select');
        jQuery(".troubleApply-tab-con").eq(self.selectIndex).show().siblings(".troubleApply-tab-con").hide();
    },
    beforeCreate() {
        var self = this;
        var $ = self.$;
    },
    data: function() {
        return {
            pageIndex:0,
            pageSize:25,
            categoryId:0,//全部类别
            gradeId:0,//全部等级
            selectContent:'',//搜索内容
            startTimeStr:"",
            endTimeStr:"",
            dshiqi : null,
            gifPath: staticPath+"img/apply/voicePlay.gif",
            imgPath: staticPath+"img/apply/voicePlay.png" ,
            noimgPath:staticPath+"img/apply/novoicePlay.png",
            selectOptionIndex:'',
            selectFlag:false,
            //隐患类别
            categoryselectOptionIndex : '',
            gradeselectOptionIndex : '',
            selectOptionOrg : "",
            test:null,
            allowInfinite:true
        }
    },
    methods: {
        backToRefresh:function(){
            var self = this;
            self.clearContent();
            self.getHiddenListData();
            self.getHiddenNum();
        },
        createTrouble:function(){
            app.router.navigate(`/createTrouble/-1/-1/-1/`);
        },

        goVerify:function(){
            app.router.navigate("/goVerify/");
        },

        loadMore:function(){
            var self = this;
            var $ = self.$$;
            if (self.allowInfinite){
                if (!self.allowInfinite) return;
                self.allowInfinite = false;
                setTimeout(function () {
                    self.pageIndex++;
                    self.getHiddenListData();
                    self.allowInfinite = true;
                }, 1000);
            }
        },

        removeScreen:function(){
            var self = this;
            if (userInfor.isMuilUnitUser == 1){//多
                if (single_Orgid == "") {
                  self.orgIds=userInfor.organizationIds;
                } else {
                  self.orgIds=single_Orgid;
                }
                jQuery("#hidden_org").html("选择单位");
                jQuery("#hidden_org").removeClass('select-active');
                self.selectOptionOrg = "";
            }
            jQuery("#hidden_level").html("隐患等级");
            jQuery("#hidden_level").removeClass('select-active');
            self.gradeId = 0;
            self.gradeselectOptionIndex = "";

            jQuery("#hidden_type").html("隐患类别");
            jQuery("#hidden_type").removeClass('select-active');
            self.categoryId=0;
            self.categoryselectOptionIndex = "";

            self.selectOptionIndex = "";
            self.startTimeStr = "";
            self.endTimeStr = "";
            jQuery("#hidden_date").html("选择日期");
            jQuery("#hidden_date").removeClass('select-active');
            self.clearContent();
            self.getHiddenListData();
            self.getHiddenNum();
        },
        //打开语音
        openVedio:function(e){
            const self = this; 
            var time = e.data.time;
            var audioId = e.data.audioId;
            var audioArray = $(".tb-voice").find("audio");
            for (var i = 0;i < audioArray.length; i++) {
                audioArray[i].pause();
            }
            var audio = $("#audioId"+audioId)[0];
            if ($("#gif"+audioId).hasClass("tb-voice-png")) {
                audio.play(); // 这个就是播放
                $("#gif"+audioId).attr('src',self.gifPath);
                $("#gif"+audioId)[0].removeAttribute("tb-voice-png");
                $("#gif"+audioId)[0].setAttribute("class","tb-voice-gif");
                $("#troubledes"+audioId).find("p").css("color",'#378bf6');
                self.dshiqi = setTimeout(function () { //dshiqi是外层定义好的一个变量！
                    $("#gif"+audioId).attr('src',self.imgPath); //播放完毕去除动画
                    $("#gif"+audioId)[0].removeAttribute("tb-voice-gif");
                    $("#gif"+audioId)[0].setAttribute("class","tb-voice-png");
                    $("#troubledes"+audioId).find("p").css("color",'#d1d1d1');
                }, time * 1000)
            } else {
                audio.pause(); // 这个就是暂停
                $("#gif"+audioId).attr('src',self.imgPath);
                $("#gif"+audioId)[0].removeAttribute("tb-voice-gif");
                $("#gif"+audioId)[0].setAttribute("class","tb-voice-png");
                $("#troubledes"+audioId).find("p").css("color",'#d1d1d1');
                clearTimeout(self.dshiqi);
            }
        },
        //获取隐患统计数据
        getHiddenNum:function(){
            var self = this;
            Dao.getHiddenManagerStatistics({
                userName:userInfor.accountName,
                deviceId:appKeyObj.deviceId,
                orgIds:self.orgIds,
                gradeId:self.gradeId==0?-1:self.gradeId,//隐患等级
                categoryId:self.categoryId==0?-1:self.categoryId,//隐患类别
                startTime:self.startTimeStr,
                endTime:self.endTimeStr
            },function(data) {
                $("#tb-changeing").empty();
                $("#tb-verify").empty();
                $("#tb-appoint").empty();
                if(data.continueNum*1<=9){
                    $("#tb-changeing").append("整改"+data.continueNum);
                }else{
                    $("#tb-changeing").append("整改9+");
                }
                if(data.checkedNum*1<=9){
                    $("#tb-verify").append("核实"+data.checkedNum);
                }else{
                    $("#tb-verify").append("核实9+");
                }
                if(data.assignNum*1<=9){
                    $("#tb-appoint").append("待指派"+data.assignNum);
                }else{
                    $("#tb-appoint").append("待指派9+");
                }
            });
        },
        //获取列表数据
        getHiddenListData:function(){
            var self = this;
            var $ = self.$;
            //筛选按钮有值变色
            if(jQuery("#hidden_org")[0].innerText != "选择单位" || jQuery("#hidden_level")[0].innerText != "隐患等级"  || jQuery("#hidden_type")[0].innerText != "隐患类别"  || jQuery("#hidden_date")[0].innerText != "选择日期"){
                jQuery("#active").addClass("select-active");
            }else{
                jQuery("#active").removeClass("select-active");
            }
            $("#trouble_preloader").show();//没分页
            Dao.getHidDangerList({
                orgIds:self.orgIds,//隐患单位
                categoryId:self.categoryId,//隐患类别
                gradeId:self.gradeId,//隐患等级
                status:self.status,//隐患状态
                queryType:1,
                pageIndex:self.pageIndex,
                pageSize:self.pageSize,
                startTime:self.startTimeStr,
                endTime:self.endTimeStr,
            },function(data, total) {
                if (data && data.length > 0){
                    if (self.pageSize * self.pageIndex + data.length < total) { //没分页
                        $("#trouble_preloader").show();
                        self.allowInfinite = true;
                    } else {  //有分页
                        $("#trouble_preloader").hide();
                        self.allowInfinite = false;
                    }
                    //整改
                    if (self.status == 1){
                        for (var i=0;i<data.length;i++) {
                            var isMoreUnit='none';
                            var flag3 = 'none';
                            if(data[i].categoryName=='消防设施'){
                                flag3 = 'true'
                            }
                            if(userInfor.isMuilUnitUser==1){
                                isMoreUnit='block';
                            }
                            //0未过期，1已过期
                            var flag = 'none';
                            if (data[i].isTimeOut == 1) {
                                flag = 'initial';
                            }
                            var flag2='none';
                            var isDuty="";
                            //责任人有整改权限
                            if (userInfor.accountName == data[i].chargePerson) {
                                flag2 = 'initial'; 
                                isDuty="goRectification_"+data[i].id;  
                            }
                            $("#troubleApplyList").append(`
                                <li id="li_goRectification_`+ data[i].id+`">
                                    <div style="padding: 15px;"> 
                                        <div id="tb-scene-image`+data[i].id+`"></div>
                                        <div id="troubledes_appint`+ data[i].id +`"></div>
                                        <div class="yh-list">
                                            <span class="eqType" style="display:`+flag3+`">故障维修</span>
                                            <span class="overtime-icon" style="display:`+flag+`">超期</span>
                                            <div class="tb-details">`+common.transNullundefinedToline(data[i].hiddenDangerDesc)+`</div>
                                        </div>
                                        <div id="li_goRectification1_`+(data[i].id)+`">
                                            <div class="right-col clearfix">
                                                <div class="time-con">`+common.transNullundefinedToline(data[i].createTime)+`
                                                    <span>`+common.transNullundefinedToline(data[i].gradeName)+`</span>
                                                    <span>`+common.transNullundefinedToline(data[i].categoryName)+`</span>
                                                </div>
                                            </div>
                                            <div class="right-col clearfix"  style="display: `+isMoreUnit+`">
                                                <i class="iconfont icon-dingweiweizhi" style="color:#2471CA; font-size: 14px;"></i> 
                                                <div class="time-con" style="position:absolute;top:3px;left:18px;">`+common.transNullundefinedToline(data[i].orgName)+`</div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="changeing-list-bottom" id="taskOutTime`+data[i].id+`" style="height:initial"></div>
                            </li>`);
                            
                            //展示图片
                            showImage(jQuery("#tb-scene-image"+data[i].id),data[i].picUrls,6);
                            //是否快要过期
                            var now = moment().format("YYYY-MM-DD HH:mm:ss");
                            var a = moment(data[i].endTime);  
                            var b = moment(now); //当前时间
                            // var c = a.diff(b,'hours');
                            //到期时间
                            var tempTime = moment.duration(a-b);
                            var mon = tempTime.months();
                            var d = tempTime.days();
                            var h = tempTime.hours();
                            var m = tempTime.minutes();
                            var s = tempTime.seconds();
                            if(tempTime<0){
                                d = 0;
                                h = 0;
                                m = 0;
                                s = 0;
                            }
                            if (moment(data[i].endTime).isAfter(common.transtimestamp(new Date()))) {
                                $("#taskOutTime"+data[i].id).html(`
                                    <div id="`+isDuty+`" style="margin-left:15px;overflow:hidden;padding-bottom: 5px;">
                                        <span class="time" ${mon>0?'':'style="display:none;"'}>`+((mon<10)?("0"+mon):mon)+`</span>
                                        <span class="dot" ${mon>0?'':'style="display:none;"'}>月</span>
                                        <span class="time">`+((d<10)?("0"+d):d)+`</span>
                                        <span class="dot">天</span>
                                        <span class="time">`+((h<10)?("0"+h):h)+`</span>
                                        <span class="dot">:</span>    
                                        <span class="time">`+((m<10)?("0"+m):m)+`</span>
                                        <span class="dot">:</span>
                                        <span class="time">`+((s<10)?("0"+s):s)+`</span>
                                        <span class="dot" style="margin-left: 2px;">后超期</span>
                                        <span class="dot have-root-to" data-id="`+data[i].id+`" style="display:`+flag2+`">
                                            <span style="width: 86px;  padding: 5px 0;color: #fff;background: #2471ca;text-align: center;border-radius: 15px;display: block;float: right;margin: 20px 15px 10px;">整改</span>
                                      
                                        </span>
                                    </div>
                                `).css("background-color","#E9F1FA");
                            }
                            //超期
                            else{
                                $("#taskOutTime"+data[i].id).html(`
                                    <div style="margin-left:15px;overflow:hidden;padding-bottom: 5px;">
                                        <span class="overdot" style="margin-left: 2px;">已超期</span>
                                        <span class="overdot have-root-to" data-id="`+data[i].id+`" style="display:`+flag2+`">
                                            <span style="width: 86px;  padding: 5px 0;color: #fff;background: #2471ca;text-align: center;border-radius: 15px;display: block;float: right;margin: 20px 15px 10px;">整改</span>
                                        </span>
                                    </div>
                                `).css("background-color","#FCF1EF");
                            }
                            jQuery(".have-root-to").off().on("click",function(e){
                            	var id = $(this).attr("data-id");
                            	self.goDetail(id);
                            });
                            let isFirstView = false;
                            //语音
                            showVoiceBtn("#troubledes_appint"+data[i].id,data[i].voiceLength,data[i].hiddenDangerVoice);
                            //页面跳转
                            jQuery("#li_goRectification_"+data[i].id).off("click").on("click",{'data':data[i]},function(e) {
                                if(!isFirstView){
                                    var data = e.data.data;
                                    app.router.navigate("/goRectification/"+data.id+'/');
                                }
                                isFirstView = false;
                            });
                            //处理隐患
                            jQuery("#goRectification_"+data[i].id).off("click").on("click",{'data':data[i]},function(e) {
                                var data = e.data.data;
                                app.router.navigate("/goRectification/"+data.id+'/');
                            });
                            if (!self.showFlag) {
                                 // $("#goRectification_"+data[i].id).hide();
                            }
                        }
                    } 
                    //核实
                    else if (self.status == 3) {
                        for (var i=0;i<data.length;i++) {
                            //0未过期，1已过期
                            var flag = 'none';
                            var flag3 = 'none';
                            if(data[i].categoryName=='消防设施'){
                                flag3 = 'true'
                            }
                            if (data[i].isTimeOut == 1) {
                                flag = 'initial';
                            }
                            var isMoreUnit='none';
                            if(userInfor.isMuilUnitUser==1){
                                isMoreUnit='block';
                            }
                            $("#troubleApplyList").append(`
                                <li id="li_verify_`+ (data[i].id) +`">
                                    <div style="padding: 15px;"> 
                                        <div id="tb-scene-image`+data[i].id+`"></div>
                                        <div id="troubledes_appint`+ data[i].id +`"></div>
                                        <div class="yh-list">
                                            <span class="eqType" style="display:`+flag3+`">故障维修</span>
                                            <span class="overtime-icon" style="display:`+flag+`">超期</span>
                                            <div class="tb-details">`+common.transNullundefinedToline(data[i].hiddenDangerDesc)+`</div>
                                        </div>
                                        <div>
                                            <div class="right-col clearfix">
                                                <div class="time-con">`+common.transNullundefinedToline(data[i].createTime)+`<span>`+common.transNullundefinedToline(data[i].gradeName)+`</span><span>`+common.transNullundefinedToline(data[i].categoryName)+`</span></div>
                                            </div>
                                            <div class="right-col clearfix"  style="display: `+isMoreUnit+`">
                                                <i class="iconfont icon-dingweiweizhi" style="color:#2471CA;font-size: 14px;"></i> 
                                                <div class="time-con" style="position:absolute;top:3px;left:18px;">`+common.transNullundefinedToline(data[i].orgName)+`</div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="right-col clearfix col-row overTime-info" id="taskOutTime`+data[i].id+`"></div>
                                </li>
                            `);
                            //展示图片
                            showImage(jQuery("#tb-scene-image"+data[i].id),data[i].picUrls,6)
                            //语音
                            showVoiceBtn("#troubledes_appint"+data[i].id,data[i].voiceLength,data[i].hiddenDangerVoice);
                            //是否快要过期
                            var now = moment().format("YYYY-MM-DD HH:mm:ss");
                            var a = moment(data[i].endTime);  
                            var b = moment(now); //当前时间
                            var c = a.diff(b,'hours');
                            //到期时间
                            var tempTime = moment.duration(a-b);
                            var mon = tempTime.months();
                            var d = tempTime.days();
                            var h = tempTime.hours();
                            var m = tempTime.minutes();
                            var s = tempTime.seconds();
                            var isDuty="";
                            if(tempTime<0){
                                d = 0;
                                h = 0;
                                m = 0;
                                s = 0;
                            }
                            //指派人和创建人有核实权限
                            //没有指派人，创建人为核实人
                            var flag2_heshi = 'none';
                            if(data[i].managerPerson==""){
                                if(data[i].createAccount==userInfor.accountName){
                                     flag2_heshi = 'initial'; 
                                     isDuty="verify_"+data[i].id;  
                                }
                            }else{
                                if(data[i].managerPerson==userInfor.accountName){
                                     flag2_heshi = 'initial';
                                     isDuty="verify_"+data[i].id;  
                                }
                            }
                           
                            if (moment(data[i].endTime).isAfter(common.transtimestamp(new Date()))) {
                                $("#taskOutTime"+data[i].id).html(`
                                    <div id="`+isDuty+`" style="margin-left:15px;padding-top:6px;padding-bottom:6px">
                                        <span class="time" ${mon>0?'':'style="display:none;"'}>`+((mon<10)?("0"+mon):mon)+`</span>
                                        <span class="dot" ${mon>0?'':'style="display:none;"'}>月</span>
                                        <span class="time">`+((d<10)?("0"+d):d)+`</span>
                                        <span class="dot">天</span>
                                        <span class="time">`+((h<10)?("0"+h):h)+`</span>
                                        <span class="dot">:</span>    
                                        <span class="time">`+((m<10)?("0"+m):m)+`</span>
                                        <span class="dot">:</span>
                                        <span class="time">`+((s<10)?("0"+s):s)+`</span>
                                        <span class="dot" style="margin-left: 2px;">后超期</span>
                                        <span class="dot have-root-to" data-id="`+data[i].id+`" style="display:`+ flag2_heshi+`">
                                            <span style="width: 86px;  padding: 5px 0;color: #fff;background: #2471ca;text-align: center;border-radius: 15px;display: block;float: right;margin: 20px 15px 10px;">核实</span>
                                        </span>
                                    </div>
                                `);
                            }else{
                                $("#taskOutTime"+data[i].id).html(`
                                    <div style="margin-left:15px;padding-top:6px;padding-bottom:6px">
                                        <span class="overdot" style="margin-left: 2px;">已超期</span>
                                        <span class="overdot have-root-to" data-id="`+data[i].id+`" style="display:`+ flag2_heshi+`">
                                            <span style="width: 86px;  padding: 5px 0;color: #fff;background: #2471ca;text-align: center;border-radius: 15px;display: block;float: right;margin: 20px 15px 10px;">核实</span>
                                        </span>
                                    </div>
                                `);
                            }
                            
                            jQuery(".have-root-to").off().on("click",function(e){
                            	var id = $(this).attr("data-id");
                            	self.goDetail(id);
                            });

                            let isFirstView = false;
                            //核实按钮
                            jQuery("#verify_"+data[i].id).off("click").on("click",{'data':data[i]},function(e) {
                                var data = e.data.data;
                                app.router.navigate("/goVerify/"+data.id+"/");
                            });
                            //页面跳转
                            jQuery("#li_verify_"+data[i].id).off("click").on("click",{'data':data[i]},function(e) {
                                if(!isFirstView){
                                    var data = e.data.data;
                                    app.router.navigate("/goVerify/"+data.id+"/");
                                }
                                isFirstView = false;
                            });
                        }
                    } 
                    //完成
                    else if (self.status == 2) {
                        for (var i=0;i<data.length;i++) {
                            //0未过期，1已过期
                            var flag = 'none';
                            var flag3 = 'none';
                            if(data[i].categoryName=='消防设施'){
                                flag3 = 'true'
                            }
                            if (data[i].isTimeOut == 1) {
                                flag = 'initial';
                            }
                            var isMoreUnit='none';
                            if(userInfor.isMuilUnitUser==1){
                                isMoreUnit='block';
                            }
                            $("#troubleApplyList").append(`
                                <li id="troubleApplyList-`+data[i].id+`">
                                    <div style="padding: 15px;"> 
                                        <div id="tb-scene-image`+data[i].id+`"></div>
                                        <div id="troubledes_appint`+ data[i].id +`"></div>
                                        <div class="yh-list">
                                            <span class="eqType" style="display:`+flag3+`">故障维修</span>
                                            <span class="overtime-icon" style="display:`+flag+`">超期</span>
                                            <div class="tb-details">`+common.transNullundefinedToline(data[i].hiddenDangerDesc)+`</div>
                                        </div>
                                        <div id="complete`+ data[i].id +`">
                                            <div class="right-col clearfix">
                                                <div class="time-con">`+common.transNullundefinedToline(data[i].createTime)+`<span>`+common.transNullundefinedToline(data[i].gradeName)+`</span><span>`+common.transNullundefinedToline(data[i].categoryName)+`</span></div>
                                            </div>
                                            <div class="right-col clearfix"  style="display: `+isMoreUnit+`">
                                                <i class="iconfont icon-dingweiweizhi" style="color:#2471CA;font-size: 14px;"></i> 
                                                <div class="time-con" style="position:absolute;top:3px;left:18px;">`+common.transNullundefinedToline(data[i].orgName)+`</div>
                                            </div>
                                        </div>
                                    </div>
                                </li>
                            `);
                            //语音
                            showVoiceBtn("#troubledes_appint"+data[i].id,data[i].voiceLength,data[i].hiddenDangerVoice);
                            //展示图片
                            showImage(jQuery("#tb-scene-image"+data[i].id),data[i].picUrls,6)
                            let isFirstView = false; 
                            //页面跳转
                            jQuery("#troubleApplyList-"+data[i].id).off("click").on("click",{'tbId':data[i].id},function(e) {
                                if(!isFirstView){
                                    var tbId = e.data.tbId;
                                    app.router.navigate("/finishMsg/"+tbId+"/");
                                }
                                isFirstView = false;
                            });
                        }
                    }
                    //指派
                    else if (self.status == 5){
                        for (var i=0;i<data.length;i++) {
                            var flag='none';
                            var flag1='block';
                            if (userInfor.accountName == data[i].managerPerson) {
                                flag = 'block';
                                flag1='none';
                            }
                            var isMoreUnit='none';
                            if(userInfor.isMuilUnitUser==1){
                                isMoreUnit='block';
                            }
                            let isCategoryNameShow = 'none';
                            if(data[i].categoryName){
                                isCategoryNameShow='block';
                            }
                            $("#troubleApplyList").append(`
                                <li id="li_goAppoint_`+ data[i].id+`">
                                    <div style="padding: 15px;"> 
                                        <div id="tb-scene-image`+data[i].id+`"></div>
                                        <div id="troubledes_appint`+ data[i].id +`"></div>
                                        <div class="yh-list">
                                            <span class="eqType" style="display: `+ isCategoryNameShow+`">`+common.transNullundefinedToline(data[i].categoryName)+`</span>
                                            <div class="tb-details">`+common.transNullundefinedToline(data[i].hiddenDangerDesc)+`</div>
                                        </div>
                                        <div id="li_appoint_`+(data[i].id)+`">
                                            <div class="right-col clearfix">
                                                <div class="time-con">`+common.transNullundefinedToline(data[i].createTime)+`</div>
                                            </div>
                                            <div class="right-col clearfix"  style="display: `+isMoreUnit+`">
                                                <i  class="iconfont icon-dingweiweizhi" 
                                                    style="
                                                    color:#2471CA;
                                                    font-size: 12px;    
                                                    float: left;
                                                    margin-right: 2px;"></i>
                                                <div class="time-con">`+common.transNullundefinedToline(data[i].orgName)+`</div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="right-col clearfix col-row">
                                        <div class="toDo-con" id="goAppoint_`+(data[i].id)+`" style="display: `+ flag+`">
                                            <img class="wait-icon" src="/ilink-app-h5-zd/static/img/rdspFile_1553173459328.png"/>等待您指派
                                            <div class="appoint-to-do">指派</diV>
                                        </div>
                                        <div class="toDo-other-con"  style="display: `+ flag1+`">
                                            <img class="wait-icon" src="/ilink-app-h5-zd/static/img/rdspFile_1553173390313.png"/>等待`+data[i].managerPersonName+`指派
                                        </div>
                                    </div>
                                </li>
                            `);
                            let isFirstView = false;
                            //展示图片
                            showImage(jQuery("#tb-scene-image"+data[i].id),data[i].picUrls,6)
                            //语音
                            showVoiceBtn("#troubledes_appint"+data[i].id,data[i].voiceLength,data[i].hiddenDangerVoice);
                            //指派隐患
                            jQuery("#goAppoint_"+data[i].id).off("click").on("click",{'data':data[i]},function(e) {
                                var data = e.data.data;
                                app.router.navigate("/goAppoint/"+data.id+'/');
                            });
                            //页面跳转
                            jQuery("#li_goAppoint_"+data[i].id).off("click").on("click",{'data':data[i]},function(e) {
                                if(!isFirstView){
                                    var data = e.data.data;
                                    app.router.navigate("/goAppoint/"+data.id+'/');
                                }
                                isFirstView = false;
                            });
                        }
                    }
                } 
                else { //暂无数据
                    $("#trouble_preloader").hide();
                    if (self.pageIndex == 0) {
                        $("#troubleApplyList").append(`<div class="no-data-img"><img src="`+listNoDataPic()+`"/></div>`);
                    }
                }
            });
        },
        
        //跳转详情页面
        goDetail:function(data) {
        	var self = this;
        	// 1-整改  2-已完成 3-核实中   5-待指派
            if(self.status == 1) {  
            	app.router.navigate("/goRectification/"+data+"/");
            }  
            
            if(self.status == 3) {  
            	app.router.navigate("/goVerify/"+data+"/");
            } 
            
            if(self.status == 5) {  
            	app.router.navigate("/goAppoint/"+data+"/");
            } 
        },
 
        //获取隐患类别
        getHiddenLevel:function(){
            var self = this;
            Dao.getDict({
                userName:userInfor.accountName,
                deviceId:appKeyObj.deviceId,
                code:50,
            },function(data) {
                if (data.dictValueObj&&data.dictValueObj.length>0){
                    var touBType = [];
                    var json = JSON.parse(data.dictValueObj[0].dictValue);
                    for (var i = 0;i < json.length > 0;i++){
                        var obj = {};
                        obj.id= json[i].id;
                        obj.name= json[i].text;
                        touBType.push(obj);
                    }

                    jQuery("#hidden_type").click(function(e) {
                        selectOptionFn(touBType,function(data){
                            if(self.categoryId==data.id){
                                jQuery("#hidden_type").html("隐患类别");
                                jQuery("#hidden_type").removeClass('select-active');
                                self.categoryId=0;
                            }else{
                                jQuery("#hidden_type").html(data.name);
                                jQuery("#hidden_type").addClass('select-active');
                                self.categoryId=data.id;
                            }
                            if(self.categoryselectOptionIndex != data.index){
                                self.categoryselectOptionIndex = data.index;
                            }else{
                                self.categoryselectOptionIndex = "";
                            }
                            self.clearContent();
                            self.getHiddenListData();
                            self.getHiddenNum();
                        },self.categoryselectOptionIndex,1);
                    });
                }
            },function(e) {});
        },
        //获取隐患等级
        getHiddenType:function(){
            var self = this;
            //等级
            Dao.getDict({
               userName: userInfor.accountName,
               deviceId: appKeyObj.deviceId,
               code: 49,
            }, function (data) {
                var touBType = [];
                if (data.dictValueObj && data.dictValueObj.length > 0) {
                   var result = data.dictValueObj;
                    for (var i = 0;i < result.length > 0;i++){
                        var obj = {};
                        obj.id= result[i].dictKey;
                        obj.name= result[i].dictValue;
                        touBType.push(obj);
                    }
                    //隐患等级
                    jQuery("#hidden_level").click(function(e) {
                        selectOptionFn(touBType,function(data){
                            if(self.gradeId == data.id){
                                jQuery("#hidden_level").html("隐患等级");
                                jQuery("#hidden_level").removeClass('select-active');
                                self.gradeId = 0;
                            }else{
                                jQuery("#hidden_level").html(data.name);
                                jQuery("#hidden_level").addClass('select-active');
                                self.gradeId = data.id;
                            }
                            if(self.gradeselectOptionIndex != data.index){
                                self.gradeselectOptionIndex = data.index;
                            }else{
                                self.gradeselectOptionIndex = "";
                            }
                            self.clearContent();
                            self.getHiddenListData();
                            self.getHiddenNum();
                        },self.gradeselectOptionIndex);
                    });
                }
            },function(e) {});
        },
        clearContent:function() {
            this.pageIndex = 0;
            if (userInfor.isMuilUnitUser == 0) {
                if (this.startTimeStr!='' || this.gradeId!=0 || this.categoryId!=0){
                    $("#tb-search").addClass('search-select');
                } else {
                    $("#tb-search").removeClass('search-select');
                }
            } else {
                if (this.startTimeStr!='' || this.gradeId!=0 || this.categoryId!=0 || this.orgIds.toString().indexOf(",").length<0){
                    $("#tb-search").addClass('search-select');
                } else {
                    $("#tb-search").removeClass('search-select');
                }
            }
            self.allowInfinite = true;
            $('#troubleApplyList').empty();
        },
        //时间筛选
        getTbTime:function(){
            var self = this;
            //type 0:年 1:年月 2：月日
            let date = common.getTimeArray(1);
            selectOptionFn(date,function(data){
                jQuery("#hidden_date").empty();
                if(self.selectOptionIndex != data.index){
                    var timeArr = data.name;
                    jQuery("#hidden_date").html(timeArr);
                    jQuery("#hidden_date").addClass('select-active');
                    self.selectOptionIndex = data.index;
                    self.startTimeStr = timeArr.replace("年", "-").replace("月", "-") + "01" + " 00:00:00";
                    let endDay = mGetDate(self.startTimeStr.split("-")[0], self.startTimeStr.split("-")[1]);
                    self.endTimeStr = timeArr.replace("年", "-").replace("月", "-") + endDay +  " 23:59:59";
                }else{
                    self.selectOptionIndex = "0";
                    self.startTimeStr = "";
                    self.endTimeStr = "";
                    jQuery("#hidden_date").html("选择日期");
                    jQuery("#hidden_date").removeClass('select-active');
                }
                self.clearContent();
                self.getHiddenListData();
                self.getHiddenNum();
            },self.selectOptionIndex);
        },
    },
    on: {
        pageInit: function(e, page) {
            var self = this;
            var $ = self.$;
            indexFlag=0;
            self.getHiddenLevel();
            self.getHiddenType();
            jQuery(".troubleApply-type div").off('click').click(function(e) {
                if(getClickEnabel()){
                    jQuery(".troubleApply-tab-con").scrollTop(0);
                    var tab_index = jQuery(".troubleApply-type div").index(e.currentTarget);
                    jQuery(e.currentTarget).addClass("select").siblings().removeClass("select");
                    jQuery(".troubleApply-tab-con").eq(tab_index).show().siblings(".troubleApply-tab-con").hide();
                    $("#trouble_preloader").hide();
                    // tab_index 0 整改中 1核实中 2已完成
                    if (tab_index == 1) {
                        self.status = 1;
                        hiddenDangerListStatus=0;
                    } else if (tab_index == 2) {
                        self.status = 3;
                        hiddenDangerListStatus=1;
                    } else if (tab_index == 3) {
                        self.status = 2;
                        hiddenDangerListStatus=2;
                    }else if (tab_index == 0) {
                        self.status = 5;
                        hiddenDangerListStatus=5;
                    }
                    self.clearContent();
                    self.getHiddenListData();
                }
            })
            if(hiddenDangerListStatus==0){
                jQuery(".troubleApply-type div").eq(1).addClass("select").siblings().removeClass("select");
                jQuery(".troubleApply-tab-con").eq(1).show().siblings(".troubleApply-tab-con").hide();
                self.status = 1;
            }else if (hiddenDangerListStatus == 1) {
                jQuery(".troubleApply-type div").eq(2).addClass("select").siblings().removeClass("select");
                jQuery(".troubleApply-tab-con").eq(2).show().siblings(".troubleApply-tab-con").hide();
                self.status = 3;
            } else if (hiddenDangerListStatus == 2) {
                jQuery(".troubleApply-type div").eq(3).addClass("select").siblings().removeClass("select");
                jQuery(".troubleApply-tab-con").eq(3).show().siblings(".troubleApply-tab-con").hide();
                self.status = 2;
            }else if (hiddenDangerListStatus == 5) {
                jQuery(".troubleApply-type div").eq(0).addClass("select").siblings().removeClass("select");
                jQuery(".troubleApply-tab-con").eq(0).show().siblings(".troubleApply-tab-con").hide();
                self.status = 5;
            }
            self.clearContent();
            self.getHiddenListData();
            self.getHiddenNum();
            //选择单位
            jQuery("#hidden_org").click(function(e) {
                loadSelectUnitFunc(function(data){
                    //选中
                    if(self.selectOptionOrg != data.orgId){
                        self.selectOptionOrg = data.orgId;
                        self.orgIds=data.orgId;
                        jQuery("#hidden_org").html(data.orgName);
                        jQuery("#hidden_org").addClass('select-active');
                    } else {
                        self.selectOptionOrg = "";
                        if (single_Orgid == "") {
                          self.orgIds=userInfor.organizationIds;
                        } else {
                          self.orgIds=single_Orgid;
                        }
                        jQuery("#hidden_org").html("选择单位");
                        jQuery("#hidden_org").removeClass('select-active');
                    }
                    self.clearContent();
                    self.getHiddenListData();
                    self.getHiddenNum();
                },self.selectOptionOrg);
            });
            jQuery("#trouble_search").keypress(function(event) {
                if (event.which == 13) {
                    self.selectContent = $("#trouble_search")[0].value;
                    self.clearContent();
                    self.getHiddenListData();
                    $("#trouble_search").blur();
                };
            });
            if (userInfor.isMuilUnitUser == 0){//单
                self.orgIds = userInfor.organizationIds;
                $("#hidden_org").hide();
            } else {//多
                if (single_Orgid == "") {
                  self.orgIds=userInfor.organizationIds;
                } else {
                  self.orgIds=single_Orgid;
                }
                $("#hidden_org").show();
            }
            //重现筛选条件
            if(localStorage.getItem("ilink_select_option")){
                var selectHistory = JSON.parse(localStorage.getItem("ilink_select_option"));
                if(selectHistory.page == "troubleApply"){
                    self.orgIds = selectHistory.organizationIds;
                    jQuery("#hidden_org").html(selectHistory.orgName).addClass('select-active');
                }
            }
        },
        // pageAfterIn: function(e, page) {
        //    var self = this;
        //    var $ = self.$;
        //    indexHiddenDangerStatus=0;
        //    hiddenDangerListStatus=0;
        // },
        pageBeforeOut: function(e, page) {
            var self = this;
            if(self.orgIds != userInfor.organizationIds){
                let params = {
                    page:'troubleApply',
                    organizationIds:self.orgIds,
                    orgName:jQuery("#hidden_org").html(),
                }
                saveSelectOption(params);
            }
        },
        pageBeforeRemove: function(e, page) {
           hiddenDangerListStatus=0;
        }
    }
}
</script>